import React, { useEffect, useState } from 'react'
import Item from './Item'
import PubSub from 'pubsub-js'
export default function List() {
    const [searchList,setsearchList]= useState({isInit:true,isSearch:false,data:[]})
    useEffect(()=>{
        PubSub.subscribe('github',(_,data)=>{
            setsearchList(data)
        })
    })

  return (
    <div>
        {
            searchList.isInit?<h2>请开始搜索</h2>:
                searchList.isSearch?<h2>正在开始搜索。。。。</h2>:
                searchList.data.map(item=>{
                    return<Item key={item.di} {...item}/>
                })

        }
    </div>
  )
}
